Allow escaping of comment char.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 8 Mar 2003 03:43:55 +0000 (03:43 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 8 Mar 2003 03:43:55 +0000 (03:43 +0000)
gpsbabel/mkstyle.sh
gpsbabel/xcsv.c

index db643ca7e419a269e2c9b10eed5e2a2b350326e8..cf5650bce329030414a139741a5d24d393a7813d 100755 (executable)
@@ -5,7 +5,7 @@ do
        [ $A = "README" ] && continue
        ALIST="{ \"$A\", $A } , $ALIST"
        echo "static char $A[] = "
-       sed 's/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i 
+       sed 's/\\/\\\\/;s/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i 
        echo ";"
 
 done
index 9281223990aedc7e48241bee56b39493aaeb1bfd..24f7df3fc7d0eaa8a0f2e14a8bce9455679bea2f 100644 (file)
@@ -173,8 +173,14 @@ xcsv_parse_style_line(const char *sbuff)
      */
 
     /* whack off any comments */
-    if ((p = strchr(sbuff, '#')) != NULL)
-       *p = '\0';
+    if ((p = strchr(sbuff, '#')) != NULL) {
+           if ((p > sbuff) && p[-1] == '\\') {
+               memmove(p-1, p, strlen(p));
+               p[strlen(p)-1] = '\0';
+           } else {
+               *p = '\0';
+           }    
+    }
 
     if (strlen(sbuff)) {
        if (ISSTOKEN(sbuff, "FIELD_DELIMITER")) {